import java.util.Arrays;

public class DecodeMessage {

    public static void main(String[] args) {
        DecodeMessage decodeMessage = new DecodeMessage();
        System.out.println(decodeMessage.decodeMessage("the quick brown fox jumps over the lazy dog", "vkbs bs t suepuv"));
    }

    public String decodeMessage(String key, String message) {
        char[] keyChars = key.toCharArray();
        int[] temp = new int[26];
        Arrays.fill(temp, -1);
        int index = 0;
        for (int i = 0; i < keyChars.length; i++) {
            char c = keyChars[i];
            if (c != ' ' && temp[c - 'a'] == -1) {
                temp[c - 'a'] = index + 'a';
                ++index;
            }
        }
        char[] ans = message.toCharArray();
        for (int i = 0; i < ans.length; i++) {
            if (ans[i] != ' ') {
                ans[i] = (char) temp[ans[i] - 'a'];
            }
        }
        return new String(ans);
    }
}
